// 创建节点 vnode-->dom
export default function createElement(vnode) {
    let domNode = document.createElement(vnode.sel);
    // innerhtml ==> text or children?
    if (vnode.text != '' && (vnode.children == undefined || vnode.children.length == 0)) {
        // innerhtml = text
        domNode.innerText = vnode.text;
    } else if (Array.isArray(vnode.children) && vnode.children.length > 0) {
        // innerhtml = children
        // 递归创建子节点
        for (var i = 0; i < vnode.children.length; i++) {
            domNode.appendChild(createElement(vnode.children[i]))
        }
    }
    vnode.elm = domNode;
    return vnode.elm;
}